#VEGETAION LAYER FOR LOWER SC (INCLUDES ARUNDO)
#read in veg layer for lower Santa Clara Watershed
bios_veg_layer <- st_read(here("bios_veg_layer", "ds983.gdb")) %>%
filter(!st_is_empty(.)) %>%
clean_names()
## Reading layer `ds983' from data source
## `/Users/irisfoxfoot/Desktop/scr_restoration_potential/bios_veg_layer/ds983.gdb'
## using driver `OpenFileGDB'
## Simple feature collection with 1546 features and 23 fields
## Geometry type: MULTIPOLYGON
## Dimension: XY
## Bounding box: xmin: 67364.41 ymin: -422907 xmax: 120390.6 ymax: -394134
## Projected CRS: NAD83 / California Albers
Insert link to data here
#TERRESTRIAL BIODIVERSITY LAYERS FROM ACE
#terrestrial rare species
t_rare_species <- st_read(here("ACE_Summary_Datasets", "ACE_Summary_Datasets", "ds2709.gdb"))
## Reading layer `ds2709' from data source
## `/Users/irisfoxfoot/Desktop/scr_restoration_potential/ACE_Summary_Datasets/ACE_Summary_Datasets/ds2709.gdb'
## using driver `OpenFileGDB'
## Simple feature collection with 63890 features and 17 fields
## Geometry type: MULTIPOLYGON
## Dimension: XY
## Bounding box: xmin: -373987.9 ymin: -604495.8 xmax: 540034.3 ymax: 450023.2
## Projected CRS: NAD83 / California Albers
#terrestrial irreplaceable habitat
t_irreplaceable_habitat <- st_read(here("ACE_Summary_Datasets", "ACE_Summary_Datasets", "ds2715.gdb"))
## Reading layer `ds2715' from data source
## `/Users/irisfoxfoot/Desktop/scr_restoration_potential/ACE_Summary_Datasets/ACE_Summary_Datasets/ds2715.gdb'
## using driver `OpenFileGDB'
## Simple feature collection with 63890 features and 17 fields
## Geometry type: MULTIPOLYGON
## Dimension: XY
## Bounding box: xmin: -373987.9 ymin: -604495.8 xmax: 540034.3 ymax: 450023.2
## Projected CRS: NAD83 / California Albers
#....etc
Insert link to data here
#RASTER OF ARUNDO 2006 (used for extent purposes)
arundo_06 <- raster(here("arundo_05", "arundo_cov_05.tif"))
arundo_06
## class : RasterLayer
## dimensions : 2992, 5366, 16055072 (nrow, ncol, ncell)
## resolution : 10, 10 (x, y)
## extent : 67134.41, 120794.4, -423477, -393557 (xmin, xmax, ymin, ymax)
## crs : +proj=aea +lat_0=0 +lon_0=-120 +lat_1=34 +lat_2=40.5 +x_0=0 +y_0=-4000000 +datum=NAD83 +units=m +no_defs
## source : arundo_cov_05.tif
## names : arundo_cov_05
## values : 0, 100 (min, max)
In this section biodiversity data will be rasterized, clipped, etc. other small changes to initial format of data will take place here.
#CONVERT TERRESTRIAL RARE SPECIES POLYGON TO RASTER
#rasterize the polygon, using RarRankEco as the raster value
t_rare_species_raster <- fasterize(t_rare_species, arundo_06, "RarRankEco")
#plot
plot(t_rare_species_raster)
#extract terrestrial rare species score values for each veg polygon
extract_t_rare_species <- raster::extract(t_rare_species_raster, bios_veg_layer, method="simple", fun=mean, weights=TRUE, normalizeWeights=TRUE, sp = TRUE)
#convert to sf (sf makes a polygon layer like a dataframe so you can use tidyverse commands on it)
extract_t_rare_sf <- st_as_sf(extract_t_rare_species)
#fixing STUPID geometry issues with this BROKEN ASS LAYER
sf::sf_use_s2(FALSE) #updated version of the sf package causes troubles so not using it
## Spherical geometry (s2) switched off
extract_t_rare_sf %>% st_buffer(dist = 0)
## Simple feature collection with 1545 features and 24 fields
## Geometry type: POLYGON
## Dimension: XY
## Bounding box: xmin: 67364.41 ymin: -422907 xmax: 120390.6 ymax: -394134
## Projected CRS: NAD83 / California Albers
## First 10 features:
## nvcsname
## 1 Lepidospartum squamatum
## 2 Barren
## 3 Populus fremontii
## 4 Salix exigua
## 5 Populus trichocarpa–Salix laevigata
## 6 Baccharis salicifolia
## 7 Mediterranean California naturalized annual and perennial grassland
## 8 Urban
## 9 Urban
## 10 Southwestern North American Riparian, Flooded and Swamp Forest/Scrubland
## nvcslevel mapclass
## 1 Alliance Lepidospartum squamatum
## 2 <NA> Riverwash
## 3 Alliance Populus fremontii
## 4 Alliance Salix exigua
## 5 Association Populus balsamifera - Salix laevigata
## 6 Alliance Baccharis salicifolia
## 7 Group Non-native grasses and forbs
## 8 <NA> Developed
## 9 <NA> Developed
## 10 Macrogroup Riverwash scrub
## alliance arundo_cov tamarix mu_source poly_number
## 1 Lepidospartum squamatum 0 Field data 6013
## 2 Riverwash 0 No PhotoInterp 0
## 3 Populus fremontii 0 No PhotoInterp 0
## 4 Salix exigua 0 No PhotoInterp 0
## 5 Populus balsamifera 50 No Field data 4114
## 6 Baccharis salicifolia 0 No Field data 4008
## 7 Non-native grasses and forbs 0 No PhotoInterp 0
## 8 Developed 0 No PhotoInterp 0
## 9 Developed 0 No PhotoInterp 0
## 10 Riverwash scrub 0 No PhotoInterp 0
## uid calvegname calvegcode cwhrtype
## 1 SCR0001 Riversidean Alluvial Scrub RS Coastal Scrub
## 2 SCR0002 Barren BA Barren
## 3 SCR0003 Fremont Cottonwood QF Valley Foothill Riparian
## 4 SCR0004 Willow (shrub) WL Valley Foothill Riparian
## 5 SCR0005 Black Cottonwood QX Montane Riparian
## 6 SCR0006 Baccharis (riparian) ML Valley Foothill Riparian
## 7 SCR0007 Non-Native/Invasive Forb/Grass IF Annual Grassland
## 8 SCR0008 Urban/Developed (General) UB Urban
## 9 SCR0009 Urban/Developed (General) UB Urban
## 10 SCR0010 Riparian Mixed Shrub NM Valley Foothill Riparian
## cwhrcode globalrank staterank rare cacode nvcsalliance
## 1 CSC G3 S3 Yes 32.070.00 Lepidospartum squamatum
## 2 BAR <NA> <NA> <NA> <NA> <NA>
## 3 VRI G4 S3 Yes 61.130.00 Populus fremontii
## 4 VRI G5 S4 No 61.209.00 Salix exigua
## 5 MRI <NA> <NA> Yes 61.120.09 Populus trichocarpa
## 6 VRI G5 S4 No 63.510.00 Baccharis salicifolia
## 7 AGS <NA> <NA> <NA> <NA> <NA>
## 8 URB <NA> <NA> <NA> <NA> <NA>
## 9 URB <NA> <NA> <NA> <NA> <NA>
## 10 VRI <NA> <NA> <NA> <NA> <NA>
## nvcsgroup
## 1 Mojavean semi-desert wash scrub
## 2 <NA>
## 3 Southwestern North American riparian evergreen and deciduous woodland
## 4 Southwestern North American riparian/wash scrub
## 5 Vancouverian riparian deciduous forest
## 6 Southwestern North American riparian/wash scrub
## 7 Mediterranean California naturalized annual and perennial grassland
## 8 <NA>
## 9 <NA>
## 10 <NA>
## nvcsmg
## 1 Madrean Warm Semi-Desert Wash Woodland/Scrub
## 2 <NA>
## 3 Southwestern North American Riparian, Flooded and Swamp Forest
## 4 Southwestern North American Riparian, Flooded and Swamp Forest
## 5 Western Cordilleran montane–boreal riparian scrub and forest
## 6 Southwestern North American Riparian, Flooded and Swamp Forest
## 7 California Annual and Perennial Grassland
## 8 <NA>
## 9 <NA>
## 10 Southwestern North American Riparian, Flooded and Swamp Forest/Scrubland
## acres shape_length shape_area layer geometry
## 1 2.806390 540.8866 11358.461 3.000000 POLYGON ((111742 -400401.3,...
## 2 140.228662 14133.1119 567550.453 3.603986 POLYGON ((85313.11 -402524....
## 3 13.503015 2318.2197 54651.295 3.000000 POLYGON ((96374.88 -402530....
## 4 28.799977 1818.8212 116563.347 3.000000 POLYGON ((96584.35 -402447....
## 5 7.955950 1409.3158 32200.458 3.000000 POLYGON ((96793.44 -402196....
## 6 1.914021 838.9665 7746.677 3.000000 POLYGON ((86592.05 -404044....
## 7 5.497501 1711.3135 22250.204 3.000000 POLYGON ((86308.41 -403916....
## 8 17.938057 1947.9278 72601.513 3.025759 POLYGON ((97221.06 -401983....
## 9 3.909923 1123.3439 15824.813 3.195033 POLYGON ((97240.29 -401947....
## 10 4.847574 1270.1589 19619.801 3.051057 POLYGON ((97178.42 -402045,...
#viewing
tmap_mode("view")
## tmap mode set to interactive viewing
tm_shape(extract_t_rare_species) +
tm_polygons("layer")
## Warning in sp::proj4string(obj): CRS object has comment, which is lost in output